﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    class DbHelper
    {
        private static readonly string conString = "server=.;database =Schools ;uid =sa;pwd =cyq123";

 


        public static int Addor(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(conString);
            sqlconn.Open();
            SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
            int i = sqlcmd.ExecuteNonQuery();
            return i;
        }
        public static DataTable Search(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(conString);
            sqlconn.Open();
            SqlDataAdapter sqlsr = new SqlDataAdapter(sql, sqlconn);
            DataTable dt = new DataTable();
            sqlsr.Fill(dt);
            return dt;
        }
     
    }
}
